$(function () {

    //变量抽取
    var systemlog_dataGrid = $("#systemlog_dataGrid");
    var systemlog_dialog = $("#systemlog_dialog");
    var systemlog_form = $("#systemlog_form");

    systemlog_dataGrid.datagrid({
        url: "/systemlog/list",
        fit: true,
        fitColumns: true,
        striped: true,
        singleSelect: true,
        pagination: true,
        rownumbers: true,
        toolbar: '#tb',
        columns: [[
            {
                field: "opuser", title: "操作人", width: 100, formatter: function (value, row, index) {
                if (value) {
                    return value.username;
                } else {
                    return "";
                }
            }},
            {field: 'optime', title: '操作时间', width: 100},
            {field: 'opip', title: '电脑IP', width: 100},
            {field: 'function', title: '操作方法', width: 200},
            {field: 'params', title: '参数', width: 100},
        ]]
    });

    /*systemlog_dialog.dialog({
        width: 400,
        height: 400,
        buttons: "#btns",
        closed: true,
        onClose: function () {
            systemlog_form.form("clear");
        },
        resizeable:true
    });*/

    //方法抽成对象统一管理
    var methodObj = {
        searchForm: function () {
            var keyword = $("input[name='keyword']").val();
            var startDate = $("input[name='startDate']").val();
            var endDate = $("input[name='endDate']").val();
            systemlog_dataGrid.datagrid('load', {
                keyword: keyword,
                startDate:startDate,
                endDate:endDate
            });
        },
        reload: function () {
            systemlog_dataGrid.datagrid("load",{});
            $(".search").textbox("clear");
        }
    };

    //按钮统一绑定事件
    $("a[data-cmd]").click(function () {
        var cmd = $(this).data("cmd");
        methodObj[cmd]();
    });
});
